package com.barradata.common.rxbus


import com.jakewharton.rxrelay2.PublishRelay
import io.reactivex.Observable

object RxBus {
    private val bus = PublishRelay.create<Any>().toSerialized()

    fun post(obj: Any) = bus.accept(obj)

    fun <T> toObservable(tClass: Class<T>): Observable<T> = bus.ofType(tClass)

    fun toObservable() = bus

    fun hasObservers() = bus.hasObservers()
}